﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleFMMatrix.ViewModel
{
    internal static class ExtensionMethods
    {
        internal static TResult[][] Select<TSource, TResult>(this TSource[,] source, Func<TSource, int, int, TResult> selector)
        {
            var l0 = source.GetLength(0);
            var l1 = source.GetLength(1);
            TResult[][] result = new TResult[l0][];
            for (int i = 0; i < l0; i++)
                result[i] = new TResult[l1];
            for (int i = 0; i < l0; i++)
                for (int j = 0; j < l1; j++)
                    result[i][j] = selector(source[i, j], i, j);
            return result;
        }
    }
}
